package com.example.player.controller;

import com.example.player.entity.Category;
import com.example.player.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping(value = "/category")
public class CategoryController {

    @Autowired
    CategoryMapper categoryMapper;

    @RequestMapping("/insert")
    public Long insert(Category category){
        //兄弟,你确定不要Service层么?
        category.setGmtCreate(LocalDateTime.now());
        category.setGmtModified(LocalDateTime.now());
         categoryMapper.insert(category);
         return category.getId();
    }

    @RequestMapping("/deleteById")
    public Long deleteById(Long id){
        categoryMapper.deleteById(id);
        return id;
    }

    @RequestMapping("/selectList")
    public List<Category> selectCategory(){
        return categoryMapper.selectList();
    }



}
